/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package modeladesktop.graficas;

import org.jfree.data.DomainOrder;
import org.jfree.data.general.AbstractSeriesDataset;
import org.jfree.data.general.DatasetChangeEvent;
import org.jfree.data.xy.XYDataset;
import umontreal.iro.lecuyer.probdist.FisherFDist;
//import umontreal.iro.lecuyer.probdist.FisherFDist;

/**
 *
 * @author Alvaro
 *
 * Estado: Incompleto (Falta agregar la función de distribución F o T dependiendo
 *                     del caso)
 *
 */
public class DistributionDataSet extends AbstractSeriesDataset implements XYDataset{

    private double translate;
    private FisherFDist fds;

    public DistributionDataSet(){
        this.translate = 0.0;
    }

    public double getTranslate(){
        return this.translate;
    }

    public void setTranslate(double translate){
        this.translate=translate;
        notifyListeners(new DatasetChangeEvent(this,this));
    }

    public double getXValue(int series, int item) {
        return new Double(item);
    }

    public double getYValue(int series, int item) {
        if (series == 0) {
            //Se ha de colocar la función de distribución T
            //return new Double(Math.cos(-10.0 + this.translate + (item / 10.0)));
            //Parametros(libertad1, libertad2, decimales de precision, valor x)
            return FisherFDist.cdf(2, 4, 2, item);
        }
        else {
            //Se ha de colocar la funcion de distribución F
            return new Double(2 * (Math.sin(-10.0 + this.translate + (item / 10.0))));
            //return FisherFDist.cdf(3, 6, 2, item);
        }
    }

    public int getSeriesCount() {
        return 1;
    }

    public String getSeriesName(int series) {
        if (series == 0) {
            return "Y = F(x)";
        }
        else if (series == 1) {
            return "y = 2*sine(x)";
        }
        else {
            return "Error";
        }
    }

    //Evaluaciones
    public int getItemCount(int series) {
        return 10;
    }

    public Number getX(int series, int item) {
        return new Double(item);
    }

    public Number getY(int series, int item) {
        if (series == 0) {
            return FisherFDist.cdf(2, 4, 2, item);
        }
        else {
            return new Double(2 * (Math.sin(-10.0 + this.translate + (item / 10.0))));
        }
    }

    public Comparable getSeriesKey(int i) {
        if (i==0){
            return "Y = F(x)";
        }else if (i==1){
            return "y = 2*sine(x)";
        }else{
            return "Error";
        }
    }

    public DomainOrder getDomainOrder() {
        return DomainOrder.NONE;
    }

}
